<include file='Admin/Tpl/Public/nav.html' />
<style>.text{display:none}</style>
<div class="page-content">
    <div class="container-fluid">
        <br/>
        <ol class="breadcrumb default square rsaquo sm">
            <li><a href="index.html"><i class="fa fa-home"></i></a></li>
            <li><a href="#fakelink">Teamin</a></li>
            <li class="active"> 问题管理 </li>
        </ol>
        <!--start-->
        <div class="row">
            <div class="col-sm-4 left">
                <div class="the-box">
                    <div class="table-responsive div1 div_search">
                    <form action="__URL__/add_question_act" method="post" enctype="multipart/form-data">
                        <input type="hidden" value="<PHP>echo $_GET['questionnaire_id']</PHP>" name="questionnaire_id" />
                        <div class="form-group">
                            <label>问题名称</label>
                            <input type="text" class="form-control" name="question_title">
                        </div>
                        
                        <div class="form-group">
                        <label>类型</label>
                            <select class="form-control" tabindex="2" name="question_type" onchange="show_text()">
                                <option value="3">填空</option>
                                <option value="1">单选</option>
                                <option value="2">多选</option>
                                <option value="4">单选+其他</option>
                            </select>
                        </div>
                        
                        <div class="form-group text">
                            <input class="btn btn-success" type="button" onclick="add_new_opt()" value="增加一个选项" />
                        </div>
                        
                        <div class="form-group text">
                            <label>A</label>
                            <input type="text" class="form-control" name="answer[]">
                        </div>
                        
                        <div class="form-group text">
                            <label>B</label>
                            <input type="text" class="form-control" name="answer[]">
                        </div>
                        
                        <div class="add_new_option"></div>
                        
                        <div class="form-group">
                            <input class="btn btn-primary" id="submit" type="submit" value="提交" />
                        </div>
                    </form>
                    </div>
                    <div class="table-responsive" id="hl"></div>
                 </div>
            </div>
            
            <div class="col-sm-8 right">
                <div class="the-box">
                    <div class="table-responsive div1 div_search">
                        <form action="__URL__/del_question_act/question_id" method="post">
                            <table class="table table-th-block table-hover">
                                <tr>
                                    <td style="text-align:center">答案选项</td>
                                    <td style="text-align:center">答案内容</td>
                                    <td style="text-align:center">选择人数</td>
                                    <td style="text-align:center">所占比例</td>
                                </tr>
                                <volist name="rs" id="val">
                                    <tr>
                                        <td style="text-align:center">{$val.opt}</td>
                                        <td style="text-align:center">what</td>
                                        <td style="text-align:center">{$val.num}</td>
                                        <td style="text-align:center">{$val.percent}</td>
                                    </tr>
                                </volist> 
                            </table>
                        </form>
                        <ul class="pagination success">{$rs.show}</ul>
                    </div>
                    <div class="table-responsive" id="hl"></div>
                 </div>
            </div>
        </div>
        <!--end-->
        
    </div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
function show_text(){
    if($('[name="question_type"]').val() != 3){
        $('.text').each(function(index, element) {
            $(this).show();
        });
    }else{
        $('.text').each(function(index, element) {
            $(this).hide();
        });
    }
}
//字符转ascii码：用charCodeAt();
//ascii码砖字符：用fromCharCode();
var opt='C';
var choice='';
function add_new_opt(){ 
    choice = '<div class="form-group">';
    choice+= '<label>'+opt+'</label>';
    choice+= '<input type="text" class="form-control" name="answer[]">';
    choice+= '</div>';
            
    if($(".add_new_option").html()=='')
        $('.add_new_option').html(choice);
    else
        $('.add_new_option').html($(".add_new_option").html()+choice);
                
    opt = String.fromCharCode(opt.charCodeAt() + 1);
}


// $(".delete").on("click",function(){
//         var id = $(this).attr("id");
       
//         if(confirm("确认删除?")){
//         $.ajax({
//             url:"__URL__/del_question_act",
//             data:{"question_id":id},
//             type:"post",
//             success:function(data){                         
//                window.location="__SELF__";
//             }
//         })
//         }
//  });

</script>
